#include <stdio.h>
#include <stdlib.h>

typedef struct  Node{
	int data;
	struct Node* next;
}Node , *PNode;

int a[2000] = {0};

void Insert_tail (int x , PNode* p)
{
	PNode temp1 = (PNode)malloc(sizeof(Node));
	temp1->data = x;
	PNode temp2 = *p;

	if ((*p) == NULL)
	{
		(*p) = temp1;
	}
	else
	{
		while (temp2->next != NULL)
		{
			temp2 = temp2->next;
		}
		temp2->next = temp1;
	}
	temp1->next = NULL;
}

void Print (PNode *p , int m)
{
	PNode pl = (*p);
	for (int i = 0 ; i < m ;i++)
	{
		a[i] = pl->data;
		if(i != m - 1)
			printf ("%d ", pl->data);
		else
			printf ("%d" ,pl->data);
		pl = pl->next;
	}
}

void Reverse (PNode *plist)
{
	PNode temp1 = (*plist);
	PNode temp2 , temp3 = NULL;
	while (temp1 != NULL)
	{
		temp2 = temp1->next;
		temp1->next = temp3;
		temp3 = temp1;

		temp1 = temp2;

	}
	(*plist) = temp3;
}


int main ()
{
	PNode headA = NULL;
	int m;
	scanf ("%d" ,&m);
	int tem1;
	for (int i = 0 ; i < m ; i++)
	{
		scanf ("%d" , &tem1);
		Insert_tail(tem1 , &headA);
	}

	Reverse(&headA);

	Print (&headA , m);
	printf ("\n");
	for (int i = 0 ; i < m ; i++)
	{
		if (i != m - 1)
			printf ("%d " , a[i]);
		else
			printf ("%d" , a[i]);

	}

	return 0;
}





















